/*
 *@brief the crc32 hash algorithm
 */

#include "common_hash.h"

/*{{{ crc32(const char* key)*/
uint crc32(const char* key)
{
  char *p = key;
  int len, nr;
  php_uint32 crcinit = 0;
  register php_uint32 crc;
  nr = strlen(p);
  crc = crcinit^0xFFFFFFFF;

  for (len =+nr; nr--; ++p) {
    crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF ];
  }
  return crc^0xFFFFFFFF;
}
/*}}}*/

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: noet sw=4 ts=4 fdm=marker
 * vim<600: noet sw=4 ts=4
 */

